/**
 * Created by zhengxiaodong on 5/15/2017.
 */
var constants1 = "recent1";
var constants7 = "recent7";
var constants30 = "recent30";
var constantsWeek= "week";
var constantsMonth = "month";

var dateType = ['&dateType=']

var baseDate = new Date();
var dateObj = {
    currentDay: [],
    thrityDay: [],
    sevenDay: [],
    dateArray: [],
    weekArray: [],
    monthArray: []
}

var downloadUrls = [];
//6 types 流量概况
var summaryDownloadUrls1 = ['https://sycm.taobao.com/bda/download/excel/flow/summary/flowGeneralExcel.do?dateRange=' //Tracffic Overview
];
var summaryDownloadUrls2 = ['&dateType=']; //Tracffic Overview

//Only 30days can be downloaded 流量趋势
var flowThrendDownloadUrls = ['https://sycm.taobao.com/bda/download/excel/flow/summary/flowTrendExcel.do?dateType=range&dateRange=' //Traffic trend
]

//5 types 流量来源 1 7 30 日 月
var trafficSource1 = ['https://sycm.taobao.com/bda/download/excel/flow/flowmap/FlowSourceExcel.do?sourceDataType=0&dateRange='

]
var trafficSource2 = ['&dateType=']
var trafficSource3 = ['&device=1&deviceLogicType=1&index=uv,newUv,pv,avgPv,favBuyerCnt,addCartBuyerCnt,bounceRate,orderAmt,orderBuyerCnt,orderRate,payAmt,payBuyerCnt,payRate', //PC SOURCE
                      '&device=4&deviceLogicType=2&index=uv,orderBuyerCnt,orderAmt,orderRate,payBuyerCnt,payAmt,payRate',// Wrieless source
                      '&device=4&deviceLogicType=3&index=uv,orderBuyerCnt,orderAmt,orderRate,payBuyerCnt,payAmt,payRate'// App source
                    ]

//页面离开排行 & 离开去向  1 7 日
var trafficExit1 = ['https://sycm.taobao.com/bda/download/excel/flow/flowmap/FlowExitExcel.do?device=1&deviceLogicType=1&dateRange=']
var trafficExit2 = ['&dateType=']
var trafficDirection1 = ['https://sycm.taobao.com/bda/download/excel/flow/flowmap/FlowDestExcel.do?device=1&deviceLogicType=1&dateRange=']
var trafficDirection2 = ['&dateType=']
//

// 1 7 日 页面访问排行
var visitRankDownloadUrls1 = ['https://sycm.taobao.com/bda/download/excel/flow/flowmap/PageAccessRankExcel.do?dateRange=']
var visitRankDownloadUrls2 = ['&dateType=']
var visitRankDownloadUrls3 = [
                              '&device=1&deviceLogicType=1', //Top visit pc client
                              '&device=4&deviceLogicType=3', //Top visit Taobao client
                              '&device=5&deviceLogicType=3', //Top visit Tmall client
                              '&device=3&deviceLogicType=3' //Top visit Wap client
                            ]

//1 ,7,30 日 访客分析
var visitorsAnalysisDownloadUrls1 = ['https://sycm.taobao.com/bda/download/excel/flow/visitor/periodDistributionExcel.do?dateRange=',    //Visitors distribution
        'https://sycm.taobao.com/bda/download/excel/flow/visitor/areaDistributionExcel.do?dateRange='  //Area distribution
        ]
visitorsAnalysisDownloadUrls2 = ['&dateType=']

//7 , 30, month 商品趋势
var salesTrendDownloadUrls1 = ['https://sycm.taobao.com/bda/download/excel/items/itemanaly/ItemTendencyExcel.do?dateRange=']
var salesTrendDownloadUrls2 = ['&dateType=']

//1,7,30，day 支付排行 & 访问排行
var topListDownloadUrls1 = ['https://sycm.taobao.com/bda/download/excel/items/itemanaly/ItemTopsExcel.do?topType=0&dateRange=',
                                'https://sycm.taobao.com/bda/download/excel/items/itemanaly/ItemTopsExcel.do?topType=1&dateRange=']
var topListDownloadUrls2= ['&dateType=']

// 1 7 30 日 月 周 商品效果
var commodityEffectDowanloadUrls1 = ['https://sycm.taobao.com/bda/download/excel/items/effect/ItemEffectExcel.do?orderDirection=false&orderField=itemPv&type=0&device=0&dateRange=',//全部终端
                                     'https://sycm.taobao.com/bda/download/excel/items/effect/ItemEffectExcel.do?orderDirection=false&orderField=itemPv&type=0&device=1&dateRange=',//PC端
                                     'https://sycm.taobao.com/bda/download/excel/items/effect/ItemEffectExcel.do?orderDirection=false&orderField=itemPv&type=0&device=&dateRange=',// 无线端 1 7 月
                                     'https://sycm.taobao.com/bda/download/excel/items/effect/ItemEffectExcel.do?orderDirection=false&orderField=itemPv&type=0&device=2&dateRange='// 无线端 上周 上月
                                    ]

// 7 30 周 月 交易趋势
var transactionTrendDownloadUrls1 = ['https://sycm.taobao.com/bda/download/excel/tradinganaly/overview/TendencyExcel.do?categoryId=50010422&diff=1&dateRange=',
                                     'https://sycm.taobao.com/bda/download/excel/tradinganaly/overview/TendencyExcel.do?categoryId=50010422&diff=0&dateRange='
                                    ]
//


//交易构成 终端 类目 品牌 价格 1 7 30 周 月 日
var transactionConstituteDownloadUrls1 = ['https://sycm.taobao.com/bda/download/excel/tradinganaly/constitute/DeviceDetailExcel.do?dateRange=',//终端
                                              'https://sycm.taobao.com/bda/download/excel/tradinganaly/constitute/CategoryExcel.do?dateRange=',   //类目
                                              'https://sycm.taobao.com/bda/download/excel/tradinganaly/constitute/BrandExcel.do?dateRange=',//品牌
                                              'https://sycm.taobao.com/bda/download/excel/tradinganaly/constitute/PriceBandExcel.do?dateRange='//价格
                                             ]
//

//推荐报表
var recommendationReportsDownloadUrls1 = ['https://sycm.taobao.com/adm/export.do?id=&itemId=&date=7&dateType=dynamic&dateId=1006960&app=op&desc='];
var recommendationReportsDownloadUrls2 = [ '每日必看的店铺经营关键数据，提供最近7个自然天的店铺流量关键指标、成交关键指标、以及PC端、无线端关键指标、店铺跳失、转化等相关的分析查询。&name=%E5%BA%97%E9%93%BA%E5%88%86%E6%9E%90%E6%97%A5%E6%8A%A5&owner=user&filter=[6,7]&' +
                                                 'show=[{"id":1006964},{"id":1007558},{"id":1007557},{"id":1007562},{"id":1006965},{"id":1007563},{"id":1006969},{"id":1006971},{"id":1006972},{"id":1006978},{"id":1016011},{"id":1006979},{"id":1006967},{"id":1006968},{"id":1006966},{"id":1007109},' +
                                                 '{"id":1007104},{"id":1016013},{"id":1007113},{"id":1007122},{"id":1016043},{"id":1016031},{"id":1007107},{"id":1007105},{"id":1007108}]',
                                                '店铺流量日报,提供最近7个自然天店铺流量相关的核心数据指标，轻松了解流量构成与流量质量。&name=%E5%BA%97%E9%93%BA%E6%B5%81%E9%87%8F%E6%97%A5%E6%8A%A5&owner=user&filter=[6,7]&show=[{"id":1006964},{"id":1006965},{"id":1007563},{"id":1006969},{"id":1014506},' +
                                                '{"id":1014507},{"id":1006967},{"id":1006968},{"id":1006971},{"id":1006972},{"id":1007572},{"id":1006978},{"id":1006979},{"id":1007581},{"id":1016011}]',
                                                '店铺销售日报，提供最近7个自然天店铺销售相关的核心数据指标查询。&name=%E5%BA%97%E9%93%BA%E9%94%80%E5%94%AE%E6%97%A5%E6%8A%A5&owner=user&filter=[6,7]&show=[{"id":1007101},{"id":1007102},{"id":1007104},{"id":1007113},{"id":1007122},{"id":1016043},{"id":1007105},' +
                                                '{"id":1007114},{"id":1007123},{"id":1016050},{"id":1007107},{"id":1007116},{"id":1007125},{"id":1007108},{"id":1007106},{"id":1007110}]',
                                                '无线运营人员玩转无线每日必看！提供最近7个自然天店铺无线的流量与无线的销售情况详细数据查询，手机淘宝APP、天猫APP，WAP端可以分开看啦。&name=%E5%BA%97%E9%93%BA%E6%97%A0%E7%BA%BF%E7%AB%AF%E5%88%86%E6%9E%90%E6%97%A5%E6%8A%A5&owner=user&filter=[6,7]&show=[{"id":1006978},' +
                                                '{"id":1006979},{"id":1007581},{"id":1006984},{"id":1007123},{"id":1007125},{"id":1007122},{"id":1016031},{"id":1007126},{"id":1014515},{"id":1014514},{"id":1014494},{"id":1014492},{"id":1014517},{"id":1014516},{"id":1014497},{"id":1014495},{"id":1014519},{"id":1014518},{"id":1014499},{"id":1014498}]',
                                                '店铺客户分析日报，提供最近7个自然天的店铺访客与买家关键指标，帮你分析店铺的老客户与潜在客户的构成情况。&name=%E5%BA%97%E9%93%BA%E5%AE%A2%E6%88%B7%E5%88%86%E6%9E%90%E6%97%A5%E6%8A%A5&owner=user&filter=[6,7]&show=[{"id":1006964},{"id":1007557},{"id":1016014},{"id":1007566},{"id":1007575},{"id":1007105},{"id":1014594}]',
                                                '店铺PC端分析日报，PC端运营人员每日必看数据！提供最近7个自然天店铺的PC端的流量与无线的销售情况详细数据查询。&name=%E5%BA%97%E9%93%BAPC%E7%AB%AF%E5%88%86%E6%9E%90%E6%97%A5%E6%8A%A5&owner=user&filter=[6,7]&show=[{"id":1006971},{"id":1006972},{"id":1007572},{"id":1007111},{"id":1007110},{"id":1016053},{"id":1007114},{"id":1007116},{"id":1007118},{"id":1007113},{"id":1007117},{"id":1016040}]',
                                                '店铺分析周报，每周一次的核心指标的汇总数据，提供最近4个自然周的店铺流量与销售相关的数据查询。&name=%E5%BA%97%E9%93%BA%E5%88%86%E6%9E%90%E5%91%A8%E6%8A%A5&owner=user&filter=[6,8]&show=[{"id":1007028},{"id":1007035},{"id":1007042},{"id":1007029},{"id":1007178},{"id":1007179},{"id":1007183},{"id":1007181},{"id":1007182},{"id":1016052},{"id":1016006}]',
                                                '店铺流量周报，每周一次的流量汇总数据，！提供最近4个自然周店铺PC端与无线端的数量数据分析查询。&name=%E5%BA%97%E9%93%BA%E6%B5%81%E9%87%8F%E5%91%A8%E6%8A%A5&owner=user&filter=[6,8]&show=[{"id":1007028},{"id":1007029},{"id":1007655},{"id":1007030},{"id":1007031},{"id":1007035},{"id":1007036},{"id":1007038},{"id":1007042},{"id":1007043},{"id":1007045}]',
                                                '店铺分析月报，每月一次的核心指标的汇总数据，提供最近3个自然月的店铺流量与销售相关的数据查询。&name=%E5%BA%97%E9%93%BA%E5%88%86%E6%9E%90%E6%9C%88%E6%8A%A5&owner=user&filter=[6,9]&show=[{"id":1007205},{"id":1007214},{"id":1016039},{"id":1007223},{"id":1016041},{"id":1007208},{"id":1007210},{"id":1007206},{"id":1016049},{"id":1016056},{"id":1007049},{"id":1007056},{"id":1007064},{"id":1007050},{"id":1011719},{"id":1007057},{"id":1007065},{"id":1007052}]',
                                                '店铺分析数据精简版，轻松查看最近7天店铺每日最核心的数据的（包括PC端与无线端流量、交易及转化率指标）。&name=%E5%BA%97%E9%93%BA%E5%88%86%E6%9E%90%E6%97%A5%E6%8A%A5-%E7%AE%80%E7%89%88&owner=user&filter=[6,7]&show=[{"id":1006964},{"id":1006971},{"id":1016011},{"id":1006965},{"id":1007563},{"id":1006969},{"id":1007104},{"id":1007113},{"id":1007122},{"id":1007108},{"id":1007117},{"id":1007126},{"id":1007105},{"id":1007107},{"id":1007109},{"id":1016013}]',
                                                '店铺服务分析日报，客服人员每日必看的店铺服务日报，提供最近7天每日的店铺服务质量关键指标数据，可通过数据分析改善店铺服务质量。&name=%E5%BA%97%E9%93%BA%E6%9C%8D%E5%8A%A1%E5%88%86%E6%9E%90%E6%97%A5%E6%8A%A5&owner=user&filter=[6,7]&show=[{"id":1016536},{"id":1016534},{"id":1016773},{"id":1011647},{"id":1011648},{"id":1011649},{"id":1011650}]'
                                                ]
//

//选词助手  （引流关键词）店外搜索关键词  店内搜索关键词  行业搜索关键词 1 7 日
var searchKeyWordsDownloadUrls1 = ['https://sycm.taobao.com/bda/download/excel/toolbox/wordaide/drainageSearchGbExcel.do?keyword=&dateRange=',
                                    'https://sycm.taobao.com/bda/download/excel/toolbox/wordaide/drainageSearchShopExcel.do?keyword=&dateRange=',
                                    'https://sycm.taobao.com/bda/download/excel/toolbox/wordaide/industryExcel.do?keyword=aldi&dateRange='
                                                                            ]

//


//流量入口 1 7 日
var trafficEntryDownloadUrls1 = ['https://sycm.taobao.com/bda/download/excel/flow/flowmap/FlowEntryExcel.do?device=1&deviceLogicType=1&dateRange='];
//

//行业热词榜相关 1 7 日
var hotKeysDownloadUrls1 = ['https://sycm.taobao.com/mq/download/excel/words/hotSearchWordExcel.do?device=1&dateRange=',

                                ];
var catIds=['']
//
$(function() {
    assembleDateArray();
    $("#download").click(function() {
        $(downloadUrls).multiDownload({
            "source": "server"
        });
    });

    $("#openurl").click(function() {
        window.open('https://sycm.taobao.com/portal/index.htm', 'newwindow', 'height=400,width=1200,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no')
    });
});
function RunCmd(strPath) {
    try {
        var objShell = new ActiveXObject("WScript.Shell");
        objShell.Run(strPath);
        objShell = null;
    } catch(e) {
        alert('can not find file: ' + strPath)

    }
}

Date.prototype.format = function(fmt) {
    var o = {
        "M+": this.getMonth() + 1,
        //月份
        "d+": this.getDate(),
        //日
        "h+": this.getHours(),
        //小时
        "m+": this.getMinutes(),
        //分
        "s+": this.getSeconds(),
        //秒
        "q+": Math.floor((this.getMonth() + 3) / 3),
        //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        }
    }
    return fmt;
}
Date.prototype.recoverCurrentDate = function(baseDate) {
    if (typeof(baseDate) !== "undefined") {
        console.log("baseDate " + baseDate.getDate());
        this.setDate(baseDate.getDate());
        this.setMonth(baseDate.getMonth());
        this.setYear(baseDate.getFullYear())
    }
}
Date.prototype.format = function(fmt, mdiff, ddiff, baseDate) {

    if (typeof(baseDate) !== "undefined") {
        console.log("baseDate " + baseDate.getDate());
        this.setDate(baseDate.getDate());
        this.setMonth(baseDate.getMonth()) ;
        this.setYear(baseDate.getFullYear());
    }
    this.setDate(this.getDate() - 1 - ddiff);
    var o = {
        "M+": this.getMonth() + 1 - mdiff,
        //月份
        "d+": this.getDate(),
        //日
        "h+": this.getHours(),
        //小时
        "m+": this.getMinutes(),
        //分
        "s+": this.getSeconds(),
        //秒
        "q+": Math.floor((this.getMonth() + 3) / 3),
        //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        }
    }
    this.recoverCurrentDate(baseDate) ;
    return fmt;
}

function assembleDateArray() {
    var now = new Date();
    var startDate = new Date();
    var diffDays = DateDiff(now.format("yyyy-MM-dd", 0, 0), startDate.format("yyyy-MM-dd", 3, 0));
    console.log("diffDays " + diffDays);
    dateObj.currentDay[0] = now.format("yyyy-MM-dd", 0, 0, baseDate) + "|" + now.format("yyyy-MM-dd", 0, 0, baseDate); //当天
    now.recoverCurrentDate(baseDate)
    dateObj.sevenDay[0] = now.format("yyyy-MM-dd", 0, 6, baseDate)+ "|" + now.format("yyyy-MM-dd", 0, 0, baseDate) ; //最近七天
    now.recoverCurrentDate(baseDate)
    dateObj.thrityDay[0] = now.format("yyyy-MM-dd", 0, 29, baseDate) + "|" + now.format("yyyy-MM-dd", 0, 0, baseDate) ; //最近30天
    now.recoverCurrentDate(baseDate)
    for (k = 1; k <= 12; k++) { //月，12个月可下载
        if ((now.getMonth() + 1) > k) {
            assembleMonthRange(now.getFullYear(), (now.getMonth() + 1 - k),k-1)
        } else {
            assembleMonthRange(now.getFullYear() - 1, k,k-1)
        }
      //  downloadUrls.push(summaryDownloadUrls1[0]+dateObj.monthArray[k-1]+summaryDownloadUrls2[0]+constantsMonth);十二个月
    }
    assembleMonthRange(now.getFullYear() - 1, now.getMonth(), 12,true);
   // downloadUrls.push(summaryDownloadUrls1[0]+dateObj.monthArray[12]+summaryDownloadUrls2[0]+constantsMonth);
    for (i = 0; i <= diffDays; i++) { //日，3个月内每个数据可下载
        //console.log("in loop " + now.format("yyyy-MM-dd", 0, i, baseDate))
        dateObj.dateArray[i] = now.format("yyyy-MM-dd", 0, i, baseDate) + "|" + now.format("yyyy-MM-dd", 0, i, baseDate);
     //   downloadUrls.push(summaryDownloadUrls1[0]+dateObj.dateArray[i]+summaryDownloadUrls2[0]+constants1);//
    }
    now.recoverCurrentDate(baseDate) ;
    var weekTemp = Math.floor((diffDays - now.getDay()) / 7);
    for (j = 0; j < weekTemp; j++) { //周，三个月
        dateObj.weekArray[j] = now.format("yyyy-MM-dd", 0, ((j + 1) * 7 )+ now.getDay()-2, baseDate) + "|" + now.format("yyyy-MM-dd", 0, now.getDay() - 1 + j * 7, baseDate);
       // downloadUrls.push(summaryDownloadUrls1[0]+dateObj.weekArray[j]+summaryDownloadUrls2[0]+constantsWeek);
    }
    now.recoverCurrentDate(baseDate)
    //拼接下载字符串  begin
    //流量概况
    var s1 = summaryDownloadUrls1[0]+dateObj.currentDay[0]+summaryDownloadUrls2[0]+constants1;//当天
    var s2 = summaryDownloadUrls1[0]+dateObj.sevenDay[0]+summaryDownloadUrls2[0]+constants7;//最近七天
    var s3 = summaryDownloadUrls1[0]+dateObj.thrityDay[0]+summaryDownloadUrls2[0]+constants30;//最近三十天
    var s4 = summaryDownloadUrls1[0]+dateObj.monthArray[0]+summaryDownloadUrls2[0]+constantsMonth;//上一个月
    var s5 = summaryDownloadUrls1[0]+dateObj.weekArray[0]+summaryDownloadUrls2[0]+constantsWeek;//上周
    //流量概况

    //流量趋势
    var s6 = flowThrendDownloadUrls[0]+dateObj.thrityDay[0];
    //流量趋势

    //流量来源 PC 无线 APP
    var s7 = trafficSource1[0]+dateObj.currentDay[0]+ trafficSource2[0] + constants1 +trafficSource3[0]
    var s8 = trafficSource1[0]+dateObj.sevenDay[0]+ trafficSource2[0] + constants7 +trafficSource3[0]
    var s9 = trafficSource1[0]+dateObj.thrityDay[0]+ trafficSource2[0] + constants30 +trafficSource3[0]
    var s10 = trafficSource1[0]+dateObj.monthArray[0]+ trafficSource2[0] + constantsMonth +trafficSource3[0]

    var s11 = trafficSource1[0]+dateObj.currentDay[0]+ trafficSource2[0] + constants1 +trafficSource3[1]
    var s12 = trafficSource1[0]+dateObj.sevenDay[0]+ trafficSource2[0] + constants7 +trafficSource3[1]
    var s13 = trafficSource1[0]+dateObj.thrityDay[0]+ trafficSource2[0] + constants30 +trafficSource3[1]
    var s14 = trafficSource1[0]+dateObj.monthArray[0]+ trafficSource2[0] + constantsMonth +trafficSource3[1]

    var s15 = trafficSource1[0]+dateObj.currentDay[0]+ trafficSource2[0] + constants1 +trafficSource3[2]
    var s16 = trafficSource1[0]+dateObj.sevenDay[0]+ trafficSource2[0] + constants7 +trafficSource3[2]
    var s17 = trafficSource1[0]+dateObj.thrityDay[0]+ trafficSource2[0] + constants30 +trafficSource3[2]
    var s18 = trafficSource1[0]+dateObj.monthArray[0]+ trafficSource2[0] + constantsMonth +trafficSource3[2]
    //流量来源 PC 无线 APP

    //流量去向 & 离开去向PC
    var s19 = trafficDirection1[0] + dateObj.currentDay[0] + trafficDirection2[0] + constants1;
    var s20 = trafficDirection1[0] + dateObj.sevenDay[0] + trafficDirection2[0] + constants7;

    var s21 = trafficExit1[0] + dateObj.currentDay[0] + trafficExit2[0] + constants1;
    var s22 = trafficExit1[0] + dateObj.sevenDay[0]+ trafficExit2[0] + constants7;
    //流量去向 & 离开去向PC

    //页面访问排行PC taobao Tmall Wap
    var s23 = visitRankDownloadUrls1[0]+dateObj.currentDay[0]+visitRankDownloadUrls2[0]+constants1+ visitRankDownloadUrls3[0];
    var s24 = visitRankDownloadUrls1[0]+dateObj.sevenDay[0]+visitRankDownloadUrls2[0]+constants7 + visitRankDownloadUrls3[0];

    var s25 = visitRankDownloadUrls1[0]+dateObj.currentDay[0]+visitRankDownloadUrls2[0]+constants1+ visitRankDownloadUrls3[1];
    var s26 = visitRankDownloadUrls1[0]+dateObj.sevenDay[0]+visitRankDownloadUrls2[0]+constants7 + visitRankDownloadUrls3[1];
    var s27 = visitRankDownloadUrls1[0]+dateObj.currentDay[0]+visitRankDownloadUrls2[0]+constants1+ visitRankDownloadUrls3[2];
    var s28 = visitRankDownloadUrls1[0]+dateObj.sevenDay[0]+visitRankDownloadUrls2[0]+constants7 + visitRankDownloadUrls3[2];
    var s29 = visitRankDownloadUrls1[0]+dateObj.currentDay[0]+visitRankDownloadUrls2[0]+constants1+ visitRankDownloadUrls3[3];
    var s30 = visitRankDownloadUrls1[0]+dateObj.sevenDay[0]+visitRankDownloadUrls2[0]+constants7 + visitRankDownloadUrls3[3];
    //页面访问排行PC taobao Tmall Wap

    //访客地域时段分布 1 7 30 日
    var s31 = visitorsAnalysisDownloadUrls1[0]+dateObj.currentDay[0]+visitorsAnalysisDownloadUrls2[0]+constants1;
    var s32 = visitorsAnalysisDownloadUrls1[0]+dateObj.sevenDay[0]+visitorsAnalysisDownloadUrls2[0]+constants7;
    var s33 = visitorsAnalysisDownloadUrls1[0]+dateObj.thrityDay[0]+visitorsAnalysisDownloadUrls2[0]+constants30;
    var s34 = visitorsAnalysisDownloadUrls1[1]+dateObj.currentDay[0]+visitorsAnalysisDownloadUrls2[0]+constants1;
    var s35 = visitorsAnalysisDownloadUrls1[1]+dateObj.sevenDay[0]+visitorsAnalysisDownloadUrls2[0]+constants7;
    var s36 = visitorsAnalysisDownloadUrls1[1]+dateObj.thrityDay[0]+visitorsAnalysisDownloadUrls2[0]+constants30;
    //访客地域时段分布 1 7 30 日

    //销售趋势 7 30 月
    var s37 = salesTrendDownloadUrls1[0]+dateObj.sevenDay[0]+salesTrendDownloadUrls2[0]+constants7;
    var s38 = salesTrendDownloadUrls1[0]+dateObj.thrityDay[0]+salesTrendDownloadUrls2[0]+constants30;
    var s39 = salesTrendDownloadUrls1[0]+dateObj.monthArray[0]+salesTrendDownloadUrls2[0]+constantsMonth;
    //销售趋势 7 30 月

    //商品支付 访问排行 1 7 30 日
    var s40 = topListDownloadUrls1[0]+dateObj.currentDay[0]+topListDownloadUrls2[0]+constants1;
    var s41 = topListDownloadUrls1[0]+dateObj.sevenDay[0]+topListDownloadUrls2[0]+constants7;
    var s42 = topListDownloadUrls1[0]+dateObj.thrityDay[0]+topListDownloadUrls2[0]+constants30;
    var s43 = topListDownloadUrls1[1]+dateObj.currentDay[0]+topListDownloadUrls2[0]+constants1;
    var s44 = topListDownloadUrls1[1]+dateObj.sevenDay[0]+topListDownloadUrls2[0]+constants7;
    var s45 = topListDownloadUrls1[1]+dateObj.thrityDay[0]+topListDownloadUrls2[0]+constants30;
    //商品支付 访问排行 1 7 30 日

    //商品效果 1 7 30 日 月 周
    var s46 = commodityEffectDowanloadUrls1[0]+dateObj.currentDay[0]+dateType+constants1;
    var s47 = commodityEffectDowanloadUrls1[0]+dateObj.sevenDay[0]+dateType+constants7;
    var s48 = commodityEffectDowanloadUrls1[0]+dateObj.thrityDay[0]+dateType+constants30;
    var s49 = commodityEffectDowanloadUrls1[0]+dateObj.monthArray[0]+dateType+constantsMonth;
    var s50 = commodityEffectDowanloadUrls1[0]+dateObj.weekArray[0]+dateType+constantsWeek;
    var s51 = commodityEffectDowanloadUrls1[1]+dateObj.currentDay[0]+dateType+constants1;
    var s52 = commodityEffectDowanloadUrls1[1]+dateObj.sevenDay[0]+dateType+constants7;
    var s53 = commodityEffectDowanloadUrls1[1]+dateObj.thrityDay[0]+dateType+constants30;
    var s54 = commodityEffectDowanloadUrls1[1]+dateObj.monthArray[0]+dateType+constantsMonth;
    var s55 = commodityEffectDowanloadUrls1[1]+dateObj.weekArray[0]+dateType+constantsWeek;
    var s56 = commodityEffectDowanloadUrls1[3]+dateObj.currentDay[0]+dateType+constants1;
    var s57 = commodityEffectDowanloadUrls1[3]+dateObj.sevenDay[0]+dateType+constants7;
    var s58 = commodityEffectDowanloadUrls1[3]+dateObj.thrityDay[0]+dateType+constants30;
    var s59 = commodityEffectDowanloadUrls1[3]+dateObj.monthArray[0]+dateType+constantsMonth;
    var s60 = commodityEffectDowanloadUrls1[3]+dateObj.weekArray[0]+dateType+constantsWeek;
    //

    //交易趋势 7 30 周 月
    var s61 = transactionTrendDownloadUrls1[0]+dateObj.sevenDay+dateType+constants7;
    var s62 = transactionTrendDownloadUrls1[0]+dateObj.thrityDay+dateType+constants30;
    var s63 = transactionTrendDownloadUrls1[0]+dateObj.weekArray[0]+dateType+constantsWeek;
    var s64 = transactionTrendDownloadUrls1[0]+dateObj.monthArray[0]+dateType+constantsMonth;
    var s65 = transactionTrendDownloadUrls1[1]+dateObj.sevenDay+dateType+constants7;
    var s66 = transactionTrendDownloadUrls1[1]+dateObj.thrityDay+dateType+constants30;
    var s67 = transactionTrendDownloadUrls1[1]+dateObj.weekArray[0]+dateType+constantsWeek;
    var s68 = transactionTrendDownloadUrls1[1]+dateObj.monthArray[0]+dateType+constantsMonth;
    //

    //交易构成 终端 类目 品牌 价格 1 7 30 周 月 日
    var s69 = transactionConstituteDownloadUrls1[0]+dateObj.currentDay[0] + dateType+constants1;
    var s70 = transactionConstituteDownloadUrls1[0]+dateObj.sevenDay[0] + dateType+constants7;
    var s71 = transactionConstituteDownloadUrls1[0]+dateObj.thrityDay[0] + dateType+constants30;
    var s72 = transactionConstituteDownloadUrls1[0]+dateObj.weekArray[0] + dateType+constantsWeek;
    var s73 = transactionConstituteDownloadUrls1[0]+dateObj.monthArray[0] + dateType+constantsMonth;
    var s74 = transactionConstituteDownloadUrls1[1]+dateObj.currentDay[0] + dateType+constants1;
    var s75 = transactionConstituteDownloadUrls1[1]+dateObj.sevenDay[0] + dateType+constants7;
    var s76 = transactionConstituteDownloadUrls1[1]+dateObj.thrityDay[0] + dateType+constants30;
    var s77 = transactionConstituteDownloadUrls1[1]+dateObj.weekArray[0] + dateType+constantsWeek;
    var s78 = transactionConstituteDownloadUrls1[1]+dateObj.monthArray[0] + dateType+constantsMonth;
    var s79 = transactionConstituteDownloadUrls1[2]+dateObj.currentDay[0] + dateType+constants1;
    var s80 = transactionConstituteDownloadUrls1[2]+dateObj.sevenDay[0] + dateType+constants7;
    var s81 = transactionConstituteDownloadUrls1[2]+dateObj.thrityDay[0] + dateType+constants30;
    var s82 = transactionConstituteDownloadUrls1[2]+dateObj.weekArray[0] + dateType+constantsWeek;
    var s83 = transactionConstituteDownloadUrls1[2]+dateObj.monthArray[0] + dateType+constantsMonth;
    var s84 = transactionConstituteDownloadUrls1[3]+dateObj.currentDay[0] + dateType+constants1;
    var s85 = transactionConstituteDownloadUrls1[3]+dateObj.sevenDay[0] + dateType+constants7;
    var s86 = transactionConstituteDownloadUrls1[3]+dateObj.thrityDay[0] + dateType+constants30;
    var s87 = transactionConstituteDownloadUrls1[3]+dateObj.weekArray[0] + dateType+constantsWeek;
    var s88 = transactionConstituteDownloadUrls1[3]+dateObj.monthArray[0] + dateType+constantsMonth;
    //

    //推荐报表
    var s89 = recommendationReportsDownloadUrls1+encodeURI(recommendationReportsDownloadUrls2[0]);
    var s90 = recommendationReportsDownloadUrls1+encodeURI(recommendationReportsDownloadUrls2[1]);
    var s91 = recommendationReportsDownloadUrls1+encodeURI(recommendationReportsDownloadUrls2[2]);
    var s92 = recommendationReportsDownloadUrls1+encodeURI(recommendationReportsDownloadUrls2[3]);
    var s93 = recommendationReportsDownloadUrls1+encodeURI(recommendationReportsDownloadUrls2[4]);
    var s94 = recommendationReportsDownloadUrls1+encodeURI(recommendationReportsDownloadUrls2[5]);
    var s95 = recommendationReportsDownloadUrls1+encodeURI(recommendationReportsDownloadUrls2[6]);
    var s96 = recommendationReportsDownloadUrls1+encodeURI(recommendationReportsDownloadUrls2[7]);
    var s97 = recommendationReportsDownloadUrls1+encodeURI(recommendationReportsDownloadUrls2[8]);
    var s98 = recommendationReportsDownloadUrls1+encodeURI(recommendationReportsDownloadUrls2[9]);
    var s99 = recommendationReportsDownloadUrls1+encodeURI(recommendationReportsDownloadUrls2[10]);
    //

    //引流关键词 1 7 日
    var s100 = searchKeyWordsDownloadUrls1[0]+dateObj.currentDay + dateType+constants1;
    var s101 = searchKeyWordsDownloadUrls1[0]+dateObj.sevenDay + dateType + constants7;
    //

    //流量入口 1 7 日
    var s102 = trafficEntryDownloadUrls1[0]+dateObj.currentDay  + dateType+constants1;
    var s103 = trafficEntryDownloadUrls1[0]+dateObj.sevenDay+ dateType + constants7;
    //
    downloadUrls.push(s1);
    downloadUrls.push(s2);
    downloadUrls.push(s3);
    downloadUrls.push(s4);
    downloadUrls.push(s5);

    downloadUrls.push(s6);

    downloadUrls.push(s7);
    downloadUrls.push(s8);
    downloadUrls.push(s9);
    downloadUrls.push(s10);
    downloadUrls.push(s11);
    downloadUrls.push(s12);
    downloadUrls.push(s13);
    downloadUrls.push(s14);
    downloadUrls.push(s15);
    downloadUrls.push(s16);
    downloadUrls.push(s17);
    downloadUrls.push(s18);

    downloadUrls.push(s19);
    downloadUrls.push(s20);
    downloadUrls.push(s21);
    downloadUrls.push(s22);

    downloadUrls.push(s23);
    downloadUrls.push(s24);
    downloadUrls.push(s25);
    downloadUrls.push(s26);
    downloadUrls.push(s27);
    downloadUrls.push(s28);
    downloadUrls.push(s29);
    downloadUrls.push(s30);

    downloadUrls.push(s31);
    downloadUrls.push(s32);
    downloadUrls.push(s33);
    downloadUrls.push(s34);
    downloadUrls.push(s35);
    downloadUrls.push(s36);

    downloadUrls.push(s37);
    downloadUrls.push(s38);
    downloadUrls.push(s39);

    downloadUrls.push(s40);
    downloadUrls.push(s41);
    downloadUrls.push(s42);
    downloadUrls.push(s43);
    downloadUrls.push(s44);
    downloadUrls.push(s45);

    downloadUrls.push(s46);
    downloadUrls.push(s47);
    downloadUrls.push(s48);
    downloadUrls.push(s49);
    downloadUrls.push(s50);
    downloadUrls.push(s51);
    downloadUrls.push(s52);
    downloadUrls.push(s53);
    downloadUrls.push(s54);
    downloadUrls.push(s55);

    downloadUrls.push(s56);
    downloadUrls.push(s57);
    downloadUrls.push(s58);
    downloadUrls.push(s59);
    downloadUrls.push(s60);


    downloadUrls.push(s61);
    downloadUrls.push(s62);
    downloadUrls.push(s63);
    downloadUrls.push(s64);
    downloadUrls.push(s65);
    downloadUrls.push(s66);
    downloadUrls.push(s67);
    downloadUrls.push(s68);

    downloadUrls.push(s69);
    downloadUrls.push(s70);
    downloadUrls.push(s71);
    downloadUrls.push(s72);
    downloadUrls.push(s73);
    downloadUrls.push(s74);
    downloadUrls.push(s75);
    downloadUrls.push(s76);
    downloadUrls.push(s77);
    downloadUrls.push(s78);
    downloadUrls.push(s79);
    downloadUrls.push(s80);
    downloadUrls.push(s81);
    downloadUrls.push(s82);
    downloadUrls.push(s83);
    downloadUrls.push(s84);
    downloadUrls.push(s85);
    downloadUrls.push(s86);
    downloadUrls.push(s87);
    downloadUrls.push(s88);

    downloadUrls.push(s89);
    downloadUrls.push(s90);
    downloadUrls.push(s91);
    downloadUrls.push(s92);
    downloadUrls.push(s93);
    downloadUrls.push(s94);
    downloadUrls.push(s95);
    downloadUrls.push(s96);
    downloadUrls.push(s97);
    downloadUrls.push(s98);
    downloadUrls.push(s99);

    downloadUrls.push(s100);
    downloadUrls.push(s101);

    downloadUrls.push(s102);
    downloadUrls.push(s103);
    //拼接下载字符串 end
}

function DateDiff(d1, d2) {
    var day = 24 * 60 * 60 * 1000;
    try {
        var dateArr = d1.split("-");
        var checkDate = new Date();
        checkDate.setFullYear(dateArr[0], dateArr[1] - 1, dateArr[2]);
        var checkTime = checkDate.getTime();

        var dateArr2 = d2.split("-");
        var checkDate2 = new Date();
        checkDate2.setFullYear(dateArr2[0], dateArr2[1] - 1, dateArr2[2]);
        var checkTime2 = checkDate2.getTime();

        var cha = (checkTime - checkTime2) / day;
        return cha;
    } catch(e) {
        return false;
    }
}

function assembleMonthRange(year, month,index, isLastYearMonth) {
    var nowdays = new Date();
    if (month < 10) {
        month = "0" + month;
    }
    var firstDay = year + "-" + month + "-" + "01"; //
    var myDate = new Date(year, month, 0);
    var lastDay = year + "-" + month + "-" + myDate.getDate(); //
    if (typeof(isLastYearMonth) !== "undefined") {
        dateObj.monthArray[12] = firstDay + "|" + lastDay
    } else {
        dateObj.monthArray[index] = firstDay + "|" + lastDay
    }

}
